import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/6 16:08
 * @description 广度优先
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] queens = {{0,1},{1,0},{4,0},{0,4},{3,3},{2,4}};
        int[] king = {0, 0};
        solution.queensAttacktheKing(queens, king);
    }
    public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {
        List<List<Integer>> ans = new ArrayList<>();
        int[][] dirs = {{-1, 0}, {1,0}, {0, -1}, {0, 1}, {-1,-1}, {-1, 1}, {1, 1}, {1, -1}};
        // 标记黑皇后的位置
        char[][] board = new char[8][8];
        for (int[] qu : queens) {
            board[qu[0]][qu[1]] = 'Q';
        }
        for (int[] dir: dirs) {
            int ni = king[0] + dir[0], nj = king[1] + dir[1];
            while (ni >= 0 && ni < 8 && nj >= 0 && nj < 8 && board[ni][nj] != 'Q') {
                ni += dir[0];
                nj += dir[1];
            }
            if (ni >= 0 && ni < 8 && nj >= 0 && nj < 8) {
                ans.add(Arrays.asList(ni, nj));
            }
        }
        return ans;
    }
}
